﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataBaseTable;
using MySpace.Data;
using System.Data;

public partial class Content : System.Web.UI.Page
{
    private string type = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            type = string.IsNullOrEmpty(Request.QueryString["type"]) ? "" : Request.QueryString["type"];
            Contentbd();
        }
    }
    protected void Contentbd()
    {
        if (!string.IsNullOrEmpty(Request.QueryString["newID"]))
        {
            int ID = Convert.ToInt32(Request.QueryString["newID"]);
            string WebSubTitle_str = "";
            string newstitle_str = "";
            string newscontents_str = "";
            string addtime_str = "";
            string author_str = "";
            string hits_str = "";
            string theclass_str = "";
            if (type.Equals("news"))
            {
                NewsTable news = new NewsTable(ID);
                WebSubTitle_str = news.NewTitle + " - ";
                newstitle_str=news.NewTitle;
                newscontents_str = news.Contents;
                addtime_str = news.AddTime.ToString("yyyy-MM-dd");
                author_str ="责任编辑："+ news.Author;
                hits_str = news.hits.ToString();
                SmallClassTable sl = new SmallClassTable(news.SmallClassId);
                theclass_str = "→&nbsp;" + sl.ForBigClassName + "→&nbsp;" + sl.SmallClassName + "→&nbsp;" + news.NewTitle;
                news.hits++;
                try
                {
                news.Update();
                }
                catch
                {
                }
            }
            else if (type.Equals("dengxin"))
            {
                DengXinTable dxb = new DengXinTable(ID);
                WebSubTitle_str = dxb.NewTitle + " - ";
                newstitle_str = dxb.NewTitle;
                newscontents_str = dxb.Contents;
                addtime_str = dxb.AddTime.ToString("yyyy-MM-dd");
                author_str = "作者：" + dxb.Author;
                hits_str = dxb.hits.ToString();
                DengXinCatalogueTable dxc = new DengXinCatalogueTable(dxb.ChapterId);
                theclass_str = "→&nbsp;" + dxc.ForPeriodsName + "→&nbsp;" + dxc.ChapterName + "→&nbsp;" + dxb.NewTitle;
                dxb.hits++;
                try
                {
                    dxb.Update();
                }
                catch
                {
                }
            }
            Master.WebSubTitle += WebSubTitle_str;
            this.newstitle.Text = newstitle_str;
            this.newscontents.Text = newscontents_str;
            this.addtime.Text = addtime_str;
            this.author.Text = author_str;
            this.hits.Text = hits_str;
            theclass.Text = theclass_str;

        }
    }
}